home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / telecomm / sticpsrc.lzh / SOURCE.ARC / NETROM.H < prev    next >
C/C++ Source or Header  |  1990-04-29  |  11KB  |  311 lines

  1. /* NET/ROM support definitions */
  2.  
  3. #define NR3HLEN        15        /* length of a NET/ROM level 3 hdr */
  4. #define NR3NODESIG    0xff        /* signature for nodes broadcast */
  5. #define NR3NODEHL    7        /* nodes bc header length */
  6. #define NR4HLEN        5        /* length of a NET/ROM level 4 hdr */
  7. #define NR4ILEN        (256-NR3HLEN-NR4HLEN) /* max length of info at level 4 */
  8.  
  9. #define NRNUMCHAINS    53        /* number of chains in the */
  10.                     /* neighbor and route hash tables */
  11. #define NRRTDESTLEN    21        /* length of destination entry in */
  12.                     /* broadcast */
  13. #define NRDESTPERPACK    11        /* maximum number of destinations per */
  14.                     /* nodes packet */
  15.  
  16. #define NR4NUMCIRC    20        /* maximum number of circuits */
  17.  
  18. #if (!defined(MSDOS) || defined(LARGEDATA))
  19. #define NETROM4        1        /* level-4 only for lots of mem */
  20. #endif
  21.  
  22. /* Internal representation of NET/ROM network layer header */
  23. struct nr3hdr {
  24.     struct ax25_addr source;    /* callsign of origin node */
  25.     struct ax25_addr dest;        /* callsign of destination node */
  26.     unsigned ttl;            /* time-to-live */
  27. };
  28.  
  29. /* Internal representation of NET/ROM routing broadcast destination */
  30. /* entry */
  31. struct nr3dest {
  32.     struct ax25_addr dest;        /* destination callsign */
  33.     char alias[7];            /* ident, upper case ASCII, blank-filled */
  34.  
  35.     struct ax25_addr neighbor;    /* best-quality neighbor */
  36.     unsigned quality;        /* quality of route for this neighbor */
  37. };
  38.  
  39. /* Internal representation of NET/ROM transport layer header */
  40. struct nr4hdr {
  41.     unsigned opcode;        /* transport layer opcode */
  42. #define     NR4OMASK    0x0f        /* mask to isolate opcode */
  43. #define     NR4MORE    0x20        /* more follows flag */
  44. #define     NR4NAK        0x40        /* NAK flag */
  45. #define     NR4CHOKE    0x80        /* CHOKE flag */
  46. #define     NR4CREFUSE    0x80        /* connect request refused flag */
  47.  
  48. #define     NR4PID        0        /* network protocol extension */
  49. #define     NR4CONRQ    1        /* connect request */
  50. #define     NR4CONACK    2        /* connect acknowledge */
  51. #define     NR4DISRQ    3        /* disconnect request */
  52. #define     NR4DISACK    4        /* disconnect acknowledge */
  53. #define     NR4INFO    5        /* information */
  54. #define     NR4INFACK    6        /* information acknowledge */
  55.     unsigned char family,proto;    /* network extension family/protocol */
  56.     struct ckt {
  57.         unsigned char index;    /* circuit index */
  58.         unsigned char id;    /* circuit id */
  59.     } your,my;
  60.     unsigned char txseq;        /* transmit sequence number */
  61.     unsigned char rxseq;        /* receive sequence number */
  62.     unsigned window;        /* proposed/accepted window size */
  63.     struct ax25_addr suser;        /* callsign of originating user */
  64.     struct ax25_addr snode;        /* callsign of originating node */
  65. };
  66.  
  67. /* NET/ROM interface info. linked to interface struct */
  68. struct nriface {
  69.     char alias[7];            /* alias for this interface's node */
  70.                     /* broadcasts */
  71.     unsigned char quality;        /* NET/ROM link quality estimate */
  72.     char uplink;            /* uplink allowed here? */
  73. };
  74.  
  75. #define NULLNRIFACE    (struct nriface *)0
  76.  
  77. /* NET/ROM neighbor table structure */
  78. struct nrnbr_tab {
  79.     struct nrnbr_tab *next;        /* doubly linked list pointers */
  80.     struct nrnbr_tab *prev;
  81.     char call[AXALEN*3];        /* call of neighbor + 2 digis max */
  82.     struct interface *interface;    /* interface of neighbor's port */
  83.     unsigned refcnt;        /* how many routes for this neighbor? */
  84.     unsigned failcnt;        /* failure count on AX.25 link */
  85. };
  86.  
  87. #define NULLNTAB    (struct nrnbr_tab *)0
  88.  
  89.  
  90. /* A list of these structures is provided for each route table */
  91. /* entry.  They bind a destination to a neighbor node.    If the */
  92. /* list of bindings becomes empty, the route table entry is    */
  93. /* automatically deleted.                       */
  94.  
  95. struct nr_bind {
  96.     struct nr_bind *next;        /* doubly linked list */
  97.     struct nr_bind *prev;
  98.     unsigned char quality;        /* quality estimate */
  99.     unsigned char obsocnt;        /* obsolescence count */
  100.     unsigned char flags;
  101. #define NRB_PERMANENT    0x01        /* entry never times out */
  102.     struct nrnbr_tab *via;        /* route goes via this neighbor */
  103. };
  104.  
  105. #define NULLNRBIND    (struct nr_bind *)0
  106.  
  107.  
  108. /* NET/ROM routing table entry */
  109.  
  110. struct nrroute_tab {
  111.     struct nrroute_tab *next;    /* doubly linked list pointers */
  112.     struct nrroute_tab *prev;
  113.     struct nrroute_tab *sort;    /* link pointer when sorting */
  114.     char alias[7];            /* alias of node */
  115.     struct ax25_addr call;        /* callsign of node */
  116.     unsigned num_routes;        /* how many routes in bindings list? */
  117.     struct nr_bind *routes;        /* list of neighbors */
  118. };
  119.  
  120. #define NULLNRRTAB    (struct nrroute_tab *)0
  121.  
  122.  
  123. /* description of a NET/ROM level 4 circuit */
  124. struct nr_circ {
  125.     struct ckt my,your;        /* circuit identifiers */
  126.     struct ax25_addr suser;        /* callsign of originating user */
  127.     struct ax25_addr snode;        /* callsign of originating node */
  128.     struct ax25_addr dnode;        /* callsign of destination node */
  129.     unsigned window;        /* proposed/accepted window size */
  130.  
  131.     int state;            /* connection state */
  132. #define NR4STDISC    0        /* disconnected */
  133. #define NR4STCPEND    1        /* connection pending */
  134. #define NR4STCON    2        /* connected */
  135. #define NR4STDPEND    3        /* disconnect requested locally */
  136.  
  137.     unsigned char txseq;        /* transmit sequence number */
  138.     unsigned char txack;        /* ack'ed transmit sequence */
  139.     unsigned char rxseq;        /* receive sequence number */
  140.  
  141.     unsigned char mystate;        /* state to send to other side */
  142.     char r_choked;            /* choke received from remote */
  143.     char s_choked;            /* sent choked myself */
  144.  
  145.     char d_reason;            /* disconnect reason */
  146. #define NR4REDISC    0        /* disconnected */
  147. #define NR4REFAIL    1        /* failed */
  148. #define NR4REBUSY    2        /* busy (CHOKE) */
  149.  
  150.     int retries;            /* number of re-tries done */
  151.  
  152.     struct mbuf *txq;        /* transmit queue */
  153.     struct mbuf *rxasm;        /* receive assembly buffer */
  154.     struct mbuf *rxq;        /* receive queue */
  155.  
  156.     struct timer trtimer;        /* transport timer */
  157.     struct timer acktimer;        /* ack delay timer */
  158.     struct timer noacttim;        /* no-activity timer */
  159.  
  160.     void (*r_upcall)();        /* receive upcall */
  161.     void (*t_upcall)();        /* transmit upcall */
  162.     void (*s_upcall)();        /* state change upcall */
  163.  
  164.     char *user;            /* user pointer */
  165. };
  166.  
  167. #define NULLNRCIRC    (struct nr_circ *)0
  168.  
  169. /* description of a NET/ROM level 7 user */
  170.  
  171. struct nr_user {
  172.     struct nr_user    *next;
  173.     struct nr_user    *prev;
  174.     struct ax25_cb    *ax25_cb[2];    /* AX.25 link control blocks */
  175.     struct nr_circ    *nrcirc[2];    /* NET/ROM level 4 control blocks */
  176. #define NRU_UP        0        /* uplink (connecting user) cb's */
  177. #define NRU_DOWN    1        /* downlink (connected user) cb's */
  178.     struct interface *iface;    /* interface for connects */
  179.     int        errors;        /* command errors made sofar */
  180. };
  181. #define        NULLNRUSER    (struct nr_user *)0
  182.  
  183.  
  184. /* The NET/ROM nodes broadcast filter structure */
  185. struct nrnf_tab {
  186.     struct nrnf_tab *next;        /* doubly linked list */
  187.     struct nrnf_tab *prev;
  188.     struct ax25_addr neighbor;    /* call of neighbor to filter */
  189.  
  190.     struct interface *interface;    /* filter on this interface */
  191. };
  192.  
  193. #define NULLNRNFTAB    (struct nrnf_tab *)0
  194.  
  195.  
  196. /* The neighbor hash table (hashed on neighbor callsign) */
  197. extern struct nrnbr_tab *nrnbr_tab[NRNUMCHAINS];
  198.  
  199. /* The routes hash table (hashed on destination callsign) */
  200. extern struct nrroute_tab *nrroute_tab[NRNUMCHAINS];
  201.  
  202. /* The circuit table (index on circuit index) */
  203. extern struct nr_circ *nr_circ[NR4NUMCIRC];
  204.  
  205. /* The nodes broadcast filter table */
  206. extern struct nrnf_tab *nrnf_tab[NRNUMCHAINS];
  207.  
  208. /* filter modes: */
  209. #define NRNF_NOFILTER    0        /* don't filter */
  210. #define NRNF_REJECT    1        /* reject broadcasts from stations in list */
  211. #define NRNF_ACCEPT    2        /* accept broadcasts from stations in list */
  212. #define NRNF_EXCLUSIVE    3        /* same as accept but only traffic from listed */
  213.  
  214. /* The filter mode */
  215. extern unsigned nr_nfmode;
  216.  
  217. /* The time-to-live for NET/ROM network layer packets */
  218. extern unsigned nr_ttl;
  219.  
  220. /* The obsolescence count initializer */
  221. extern unsigned obso_init;
  222.  
  223. /* The threshhold at which routes becoming obsolete are not broadcast */
  224. extern unsigned obso_minbc;
  225.  
  226. /* The quality threshhold below which routes in a broadcast will */
  227. /* be ignored */
  228. extern unsigned nr_autofloor;
  229.  
  230. /* The maximum fail count on AX.25 links to neighbors.          */
  231. /* When this is exceeded, all routes via this neighbor are    */
  232. /* dropped from the table. (except the permanen